import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: syyyy
 * Date: 2025-07-16
 * Time: 11:23
 */
public class demo1 {
    public static int[] changeArray(int[] array){
//        array=new int[]{1,2,3};
        for (int i = 0; i < array.length; i++) {
            array[i]=array[i]*2;
        }
        return array;
    }

    public static int[] sortArrays(int[] array){
        for (int i = 0; i < array.length-1; i++) {
            boolean issort=false;
            for(int j=0;j<array.length-i-1;j++){
                if(array[j]%2==0&&array[j+1]%2!=0){
                    int tmp=array[j+1];
                    array[j+1]=array[j];
                    array[j]=tmp;
                    issort=true;
                }
            }
            if(issort==false){
                break;
            }
        }
        return array;
    }

    public static void binaryArray(int[] array,int num){
        int left=0;
        int right= array.length-1;
        int mid=(left+right)/2;
        boolean isFind=false;
        while(left<=right){
            if(num>array[mid]){
                left=mid+1;
                mid=(left+right)/2;
            }
            if(num<array[mid]){
                right=mid-1;
                mid=(left+right)/2;
            }
            if(num==array[mid]){
                System.out.println("找到啦!在下标 "+mid);
                isFind=true;
                break;
            }
        }
        if(isFind==false){
            System.out.println("没有这个数字哦");
        }

    }

    public static int[] bubbleSort(int[] array){
        for (int i = 0; i < array.length-1; i++) {
            boolean issort=false;
            for(int j =0;j<array.length-i-1;j++){
                if(array[j]>array[j+1]){
                    int tmp=array[j+1];
                    array[j+1]=array[j];
                    array[j]=tmp;
                    issort=true;
                }
            }
            if(issort==false){
                break;
            }
        }
        return array;
    }

    public static void sumArray(int[] array,int target){
        int i = 0;
        for (; i < array.length - 1; i++) {
            boolean isFind=false;
            for(int j = 1;j < array.length; j++){
                if(array[i]+array[j]==target){
                    System.out.println("target对应下标为 "+i+" "+j);
                    isFind=true;
                    break;
                }
            }
            if(isFind==true){
                break;
            }
        }
        if(i==array.length-1){
            System.out.println("找不到对应下标哦");
        }
    }

    public static int onlyApparent(int[] array) {
        int ret = 0;
        for (int i = 0; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }

    public static int majorityElement(int[] array){
        Arrays.sort(array);
        return array[array.length/2];

    }

    public static void isContinous(int[] array){
        int i = 0;
        int count=0;
        for (; i < array.length; i++) {
            if(array[i]%2!=0){
                count++;
            }
            if(array[i]%2==0){
                count=0;
            }
        }
        if(count==3){
            System.out.println("存在三个连续的奇数,下标为"+(i-2)+" "+(i-1)+" "+i);
        }
        if(count!=3){
            System.out.println("没有三个连续的奇数");
        }
    }



    public static void main(String[] args) {
//        int[] array={1,2,3};
//        changeArray(array);
//        System.out.println(Arrays.toString(array));
//        System.out.println("*****************************");
//        int[] array={1,3,6,2,9,5};
//        sortArrays(array);
//        System.out.println(Arrays.toString(array));
//        System.out.println("****************************");
//        int[] array={12,21,33,45,48,61,82};
//        Scanner scanner=new Scanner(System.in);
//        int num= scanner.nextInt();
//        binaryArray(array,num);
//        System.out.println("****************************");
//        int[] array={12,45,32,76,36,66,21};
//        bubbleSort(array);
//        System.out.println(Arrays.toString(array));
//        int[] array={1,4,3,7,11,9,6};
//        int target=scanner.nextInt();
//        sumArray(array,target);
//        System.out.println("****************************");
//        int[] array={2,2,1,6,3,6,3};
//        int ret=onlyApparent(array);
//        System.out.println(ret);
//        System.out.println("****************************");
//        int[] array={2,2,1,1,1,2,2};
//        int ret=majorityElement(array);
//        System.out.println(ret);
        System.out.println("****************************");
        int[] array={11,23,56,24,13,51,26};
        isContinous(array);




    }
}


